package util;

import java.util.ArrayList;
import java.util.HashSet;

import org.cloudbus.cloudsim.distributions.UniformDistr;

public class PokerTest2 {




	public static void main(String[] args) {

		ArrayList<HashSet<Integer>> list1 = new ArrayList<HashSet<Integer>>();
		ArrayList<ArrayList<Integer>> list2 = new ArrayList<ArrayList<Integer>>();

		int limit = 1000000;

		UniformDistr ud = new UniformDistr(0, 5, 14325351);

		for(int i = 0; i <limit; i++){

			HashSet<Integer> hs = new HashSet<Integer>();
			ArrayList<Integer> values = new ArrayList<Integer>();

			for(int j = 0; j <5; j++){
				int sample = (int) ud.sample();
				hs.add(sample);
				values.add(sample);
			}

			list1.add(hs);
			list2.add(values);
		}

		int[] scores = new int[7];

		for(int i = 0; i <limit; i++){

			HashSet<Integer> h = list1.get(i);



			switch(h.size()){
			case 5:
				scores[6]++;
				break;

			case 4:				
				scores[5]++;
				break;

			case 3:
				int[] innerScores1 = new int[5];

				//System.out.println(list2.get(i));

				for(int j = 0; j <5; j++){
					//System.out.println("int value: " + list2.get(i).get(j).intValue());
					innerScores1[list2.get(i).get(j).intValue()]++;						
				}

				boolean dcouple = true;

//				System.out.println(innerScores1[0]);
//				System.out.println(innerScores1[1]);
//				System.out.println(innerScores1[2]);
//				System.out.println(innerScores1[3]);
//				System.out.println(innerScores1[4]);

				for(int j = 0; j <5; j++){
					if(innerScores1[j] == 3){
						dcouple = false;
						break;
					}					
				}

				//System.out.println("doppia coppia? " + dcouple);

				if(dcouple)
					scores[4]++;
				else
					scores[3]++;


				break;
			case 2:

				int[] innerScores2 = new int[5];

				//System.out.println(list2.get(i));

				for(int j = 0; j <5; j++){
					//System.out.println("int value: " + list2.get(i).get(j).intValue());
					innerScores2[list2.get(i).get(j).intValue()]++;						
				}


				boolean full = true;

				for(int j = 0; j <5; j++){
					if(innerScores2[j] == 4){
						full = false;
						break;
					}					
				}

				if(full)
					scores[2]++;
				else
					scores[1]++;

				break;
			case 1:
				scores[0]++;
				break;
			}

		}

		for(int i = scores.length - 1; i >= 0; i--){
			System.out.println(scores[i] + " " + (double)scores[i]/limit);
		}


	}


}
